Program UrthWurm;

{ i saw SFCave as a Java game and thought it would be cool
  if you can play it op the pc, so i made this remake

  10-jun-2002 started program, got the the basics
  23-jun-2002 first release

  BdR 2002 }

uses
  SmallCrt, menucode, gamecode, graphics, hiscores;

procedure InitProgram;
var
  FlushKey : Char;
begin
  { load the hi-scores, the result of LoadScores is not important }
  LoadScores;
  Screenmode(19); { or 13(hex) = vga 320*200, 256 colors }
  SetPalette;
end;

procedure CloseProgram;
begin
  Screenmode(3); {text mode}
end;

procedure MainGame;
var
  FlushKey : Char;
begin
  { initialise }
  GameOver := False;
  InitialiseGame;
  { main game loop }
  repeat
    HandlePlayerInput;
    CaveStep;

    DisplayCaveSlice;

    SnakeStep;

    WaitForRetrace;

    BackGroundeffect;

    V_Flip;

  until GameOver;

  CleanupGame;

  repeat until keypressed;
    FlushKey := ReadKey;
end;

var
  MenuChoice : Boolean;

begin
  InitProgram;
  repeat
    MenuChoice := MainMenu;
    If MenuChoice Then
      MainGame;
  until MenuChoice = False;

  CloseProgram;
end.